package de.osmembrane.tools.xmlocalizr;

import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Window;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class XMLocalizr {

	public static void main(String[] args) {
		// try to set LnF to Nimbus, if available
		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				ViewFrame vf = new ViewFrame();
				vf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				vf.setVisible(true);
			}
		});
	}

	/**
	 * Centers the window.
	 * 
	 * @param w
	 */
	public static void centerWindow(Window w) {
		Point screenCenter = GraphicsEnvironment.getLocalGraphicsEnvironment()
				.getCenterPoint();
		Point edgeLeftTop = new Point(screenCenter.x - (w.getWidth() / 2),
				screenCenter.y - (w.getHeight() / 2));
		w.setLocation(edgeLeftTop.x, edgeLeftTop.y);
	}

}
